#!/usr/bin/env python3
#生成杨辉三角（帕斯卡三角）

import better_exceptions

def pascal(max):
    a = 2
    p = [1]
    yield(p)
    while a <= max:
        q = []
        for x in range(a):
            if x == 0 or x+1 > len(p):
                q.append(1)
            else:
                q.append(p[x-1] + p[x])
        a += 1
        p = q
        yield(q)

def pascal_2(max):
    #使用列表生成式将代码精简到一行
    a = 2
    p = [1]
    yield(p)
    while a <= max:
        p = [1 if x == 0 or x+1 > len(p) else p[x-1] + p[x] for x in range(a)]
        a += 1
        yield(p)
        
for n in pascal_2(10):
    print(n)